/*
 * StyledDocumentDelegate  0.4.0 / Dec 04, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#include "StyledDocumentDelegate.h"

#include "StyledDocument.h"

// TextDocumentDelegate :: Protected Constructor. ------------------------------

/*!
 * \brief Constructs new TextDocumentDelegate object.
 *
 * \param env the JNIEnv pointer
 * \param obj the StyledDocument object
 */
StyledDocumentDelegate::StyledDocumentDelegate(JNIEnv *env, jobject obj)
  : TextDocumentDelegate(env, obj, new StyledDocument(this))
{
  // empty constructor body
}

// TextDocumentDelegate :: Native Calls. ---------------------------------------

/*!
 * \brief Sets text wrap status. 
 *
 * \param env the JNIEnv pointer
 * \param wrapText if \c true the document will wrap the text
 */
void StyledDocumentDelegate::setWordWrap(JNIEnv *env, jboolean wrapText)
{
  Q_ASSERT(env);
  SWING_REENTRANT(setWordWrap, SWING_ENV_ARG, JBOOLEAN_ARG(wrapText))
  // TODO: Implement
}

// TextDocumentDelegate :: Static Native Calls. --------------------------------

/*!
 * \brief Returns new instance of the delegate object
 *
 * \param env the JNIEnv pointer
 * \param obj the Swing object
 * 
 * \return new instance of the delegate object
 */
jlong StyledDocumentDelegate::newInstance(JNIEnv *env, jobject obj)
{
  if (JNISwingWrapper::isSwingThread(env)) {
    return reinterpret_cast<jlong>(new StyledDocumentDelegate(env, obj));
  }
  return SwingUtilitiesDelegate::invokeLongAndWait(env, obj, createMID());
}
